<template>
  <div class="bgff p20">
    <el-form :inline="true" :model="formInline" class="demo-form-inline mb20">
      <el-form-item>
        <el-input v-model="formInline.input" placeholder="请输入用户名"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table
      :data="tableData"
      v-loading="loading"
      row-key="id"
      border
      style="width: 100%"
      empty-text="暂无数据"
    >
      <el-table-column
        type="index"
        width="50"
        :index="(index)=>{return (index+1) + (curPage - 1) * size }"
        label="序号"
      ></el-table-column>
      <el-table-column prop="dept.name" label="组织结构名称" min-width="120"></el-table-column>
      <el-table-column prop="createTime" label="报告月份" min-width="120">
           <template slot-scope="scope">
            {{new Date(scope.row.createTime).format('yyyy-MM')}}
          </template>
      </el-table-column>
      <el-table-column prop="createTime" label="生成时间" min-width="150">
           <template slot-scope="scope">
            {{new Date(scope.row.createTime).format('yyyy-MM-dd hh:mm:ss')}}
          </template>
      </el-table-column>
      <el-table-column fixed="right" label="操作" width="100">
        <template slot-scope="scope">
            <!-- <router-link target="_blank" :to="{path:`/monthShow/${scope.row.id}`}">详情</router-link> -->
          <el-button @click="detailClick(scope.row)" type="text" size="small">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="mt20"
      @current-change="handlePage"
      @size-change="handleSizeChange"
      :current-page.sync="curPage"
      :page-size="size"
      :page-sizes="[5,10]"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    ></el-pagination>
  </div>
</template>

<script>
import { _usersList } from "@/http/ajax";
export default {
  name: "userlist",
  data() {
    return {
      cur_this: this,
      loading: false,
      formInline: {
        input: ""
      },
      tableData: [],
      total: 0,
      size: 10,
      curPage: 1
    };
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      let data = {
        page: this.curPage - 1,
        size: this.size,
        sort: null
      };
      this.loading = true;
      _usersList(
        data,
        res => {
          this.tableData = res.content;
          this.total = res.totalElements;
          this.loading = false;
        },
        err => {}
      );
    },
    detailClick(row) {
         let routeUrl = this.$router.resolve({
          path: `/monthShow/${row.id}`,
        //   query: {id:row.id}
     });
     window.open(routeUrl.href, '_blank');
    },
    // 切换页码
    handlePage(val) {
      this.curPage = val;
      this.getList();
    },
    // 切换条数
    handleSizeChange(val) {
      this.curPage = 1;
      this.size = val;
      this.getList();
    }
  }
};
</script>

<style lang="scss" scoped>
</style>
